
window.onload = function (){
  let query = getQuery("errorInfo");
  if (query == "login"){
      $("errorInfo").innerHTML = "请先登录<br>";
      $("errorInfo").style.color = "red"
  }else if (query == "no") {
      $("errorInfo").innerHTML = "没有权限<br>";
      $("errorInfo").style.color = "red"
  }
};

async function login() {
    let user = await ajaxGet("/user/login",{
        username:$("username").value,
        pwd:$("pwd").value
    });

    if (user == "顾客"){
        location.href = "/html/index.html"
    }else if (user == "管理员"){
        location.href = "/html/manager/pressOrder.html";
    }else if (user == "送货员"){
        location.href = "/html/send/sendProduct.html";
    }else if (user == "经理"){
        location.href = "/html/leader/index.html";
    }
    else if (user == "no"){
        $("errorInfo").innerHTML = "用户名或者密码错误<br>";
        $("errorInfo").style.color = "red"
    }
}